package com.es.action.heat.exec.exectime;

import com.es.common.Cache;

import java.util.Map;

/**
 * 执行工厂
 *
 * @author Will
 */
public class ExecFactory {

    BaseStrategy strategy;

    /**
     * 工厂构造，对外抛出
     */
    public ExecFactory() {
        // 配置文件获取
        Object initStart = Cache.get("initStart");

        boolean flag = initStart == null ? false : (Boolean) initStart;
        if (flag) {
            strategy = new InitStart();
        } else {
            strategy = SaveStart.getInstance();
        }
    }

    /**
     * 运行
     *
     * @param map
     */
    public void run(Map<String, Long> map) {
        strategy.setMap(map);
        strategy.run();
    }
}
